home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1637 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Question!@#!
  5. Date: Mon, 15 Jan 96 17:30:04 GMT
  6. Organization: none
  7. Distribution: world
  8. Message-ID: <821727004snz@genesis.demon.co.uk>
  9. References: <4dcejq$2un@venus.senecac.on.ca> <15JAN199607533289@erich.triumf.ca>
  10. Reply-To: fred@genesis.demon.co.uk
  11. X-NNTP-Posting-Host: genesis.demon.co.uk
  12. X-Newsreader: Demon Internet Simple News v1.27
  13. X-Mail2News-Path: genesis.demon.co.uk
  14.  
  15. In article <15JAN199607533289@erich.triumf.ca>
  16.            bennett@erich.triumf.ca "P.Bennett" writes:
  17.  
  18. >In article <4dcejq$2un@venus.senecac.on.ca>, cweselak@learn.senecac.on.ca
  19. > (Christian Weselak) writes...
  20. >> 
  21. >>I have a very Simple question.. well, it should be simple for 'alot' of 
  22. >>you reading this newsgroup..
  23. >> 
  24. >>anyways.
  25. >> 
  26. >>I have created a program that asks THE users for his name, then writes it 
  27. >>to a file, the file is called name.txt..
  28.  
  29. Post code. We can make an educated guess as to what you're doing (and
  30. hence what you are doing wrong). If you post code we can see what you are
  31. really doing wrong and don't waste time and space with possibly false
  32. conjecture.
  33.  
  34. ...
  35.  
  36. >>How can i keep this file, name.txt, so that i can eventually have a 
  37. >>listing of all users who ran my program???
  38. >
  39. >You have to open the file in "update" mode:
  40. >
  41. >        file = fopen("name.txt","a+");
  42.  
  43. "r+", "w+", and "a+" are all 'update' modes which means the file can be both
  44. read from and written to through the open stream. If reading is not necessary
  45. then simply "a" will do the job. The important thing is to seek to the
  46. end of the file before writing. The 'append' modes "a" and "a+" do this
  47. automatically, but you could do this manually using fseek() (e.g. if
  48. the file had been opened in "r+" mode). That might be useful if it is
  49. sometimes necessary to modify data within the file.
  50.  
  51. -- 
  52. -----------------------------------------
  53. Lawrence Kirby | fred@genesis.demon.co.uk
  54. Wilts, England | 70734.126@compuserve.com
  55. -----------------------------------------
  56.